//
//  UPMainTabController.m
//  LoveFreshBee
//
//  Created by 王现涛 on 16/6/8.
//  Copyright © 2016年 王现涛. All rights reserved.
//

#import "UPMainTabController.h"
#import "UPMainNavContoller.h"
#import "UPHomeViewController.h"
#import "UPOrderViewController.h"
#import "UPMyViewController.h"
#import "UPShopCartViewController.h"
#import "UPFreshReservationViewController.h"
@interface UPMainTabController ()

@end

@implementation UPMainTabController
+(void)initialize{
//-----------------------------------------------------
//    UITabBarItem *item=[UITabBarItem appearance];
//    NSDictionary *dict=@{NSForegroundColorAttributeName:UPColor(174, 174, 174),NSFontAttributeName:[UIFont systemFontOfSize:20]};
    //改变颜色和字体大小
//-----------------------------------------------------
    UITabBarItem *item=[UITabBarItem appearance];
    NSDictionary *dict=@{NSForegroundColorAttributeName:UPColor(174, 174, 174)};
    [item setTitleTextAttributes:dict forState:UIControlStateNormal];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    //添加Home控制器
    UPHomeViewController *homeVc=[[UPHomeViewController alloc]init];
    [self addNavController:homeVc title:@"首页" imageName:@"v2_home" ];
    //添加Oder控制器
    UPOrderViewController *oderVc=[[UPOrderViewController alloc]init];
    [self addNavController:oderVc title:@"闪电超市" imageName:@"v2_order"];
   //添加ShopCart控制器
    UPShopCartViewController *shopVc=[[UPShopCartViewController alloc]init];
    [self addNavController:shopVc title:@"新鲜预定" imageName:@"shopCart"];
    //添加FreshReservation控制器
    UPFreshReservationViewController *freshReserVc=[[UPFreshReservationViewController alloc]init];
    [self addNavController:freshReserVc title:@"购物车" imageName:@"shopCart"];
    //添加My控制器
    UPMyViewController *myVc=[[UPMyViewController alloc]init];
    [self addNavController:myVc title:@"我的" imageName:@"v2_my"];
}
-(void)addNavController:(UIViewController *)controller title:(NSString *)title imageName:(NSString *)imageName {
    
    UPMainNavContoller *navVc=[[UPMainNavContoller alloc]initWithRootViewController:controller];
  //----------------------------------------------------
//    NSDictionary                                                                                  |*dict=@{NSForegroundColorAttributeName:UPColor(174, 174,    |  174)};//宏定义                                                                                   |
//    [navVc.tabBarItem setTitleTextAttributes:dict                             |forState:UIControlStateNormal];                                                     |
 //-----------------------------------------------------
    navVc.tabBarItem.title=title;//设置显示的文字
    UIImage *normalImage=[UIImage imageNamed:imageName];
    
     NSString *selectedImageName=[NSString stringWithFormat:@"%@%@",imageName,@"_r"];
    
    UIImage *selectenImage=[UIImage imageNamed:selectedImageName];
    
    //设置普通状态下的图片
    navVc.tabBarItem.image=normalImage;
    //设置选中状态的图片
    navVc.tabBarItem.selectedImage=selectenImage;
    [self addChildViewController:navVc];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
